using Digitalmes.Domain.Entities.Mes.Equipments;

namespace Digitalmes.Application.Mes.Equipments.StandardParts.Commands;

/// <summary>
/// 设备点检标件删除命令。
/// </summary>
/// <param name="Id"></param>
public sealed record DeleteStandardPartsCommand(long Id) : IRequest<IResult<bool>>;

internal sealed class DeleteStandardPartsCommandHandler(IRepository<EquipInspectionStandardParts> repo) : IRequestHandler<DeleteStandardPartsCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteStandardPartsCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.Id, cancellationToken);
        return Result.From(ok);
    }
}
